export default class Event {
  constructor(sender) {
    this._sender = sender
    // 维护事件对应的回调函数
    this._listeners = []
  }

  attach(callback) {
    this._listeners.push(callback)
  }

  // 将当前listener 中回调函数全部触发
  notify(args) {
    for (let i = 0; i < this._listeners.length; i++) {
      this._listeners[i](this._sender, args)
    }
  }
}